function initPage(medexElectricInfoJson){
	var basePath = $("#basePath").val();
	var medexElectricRecords=medexElectricInfoJson['medexElectricRecords'];//转科记录集合
	var baseServerPath = $("#baseServerPath").val();
	console.log(baseServerPath);
	for(var index in medexElectricRecords){
		var medexElectricRecord = medexElectricRecords[index];
		var add_content= addExaminationReportRecord();
		add_content.find("input[name$='.examineItemName']").val(medexElectricRecord.examineItemName);
		add_content.find("input[name$='.patientName']").val(medexElectricRecord.patientName);
		add_content.find("input[name$='.deptName']").val(medexElectricRecord.deptName);
		add_content.find("input[name$='.examineNo']").val(medexElectricRecord.examineNo);
		add_content.find("input[name$='.examineDate']").val(medexElectricRecord.examineDate);
		add_content.find("iframe[name$='.iframeKey']").attr("src",baseServerPath+medexElectricRecord.pdfFilePath);
		add_content.find("input[name$='.diseaseName']").val(medexElectricRecord.diseaseName);
		add_content.find("input[name$='.applyExamineDoctor']").val(medexElectricRecord.applyExamineDoctor);
		add_content.find("input[name$='.originalPdfPath']").val(medexElectricRecord.originalPdfPath);
		add_content.find("textarea[name$='.diagHints']").val(medexElectricRecord.diagHints);	
    }
	if($("#examination_report_ul li").length <1){
		var add_content = addExaminationReportRecord();
		if(add_content.find("table[id^='examinationReportItems'] tbody tr").length < 1){
			addExaminationReportItem();
		}
	}else{
		$("#examination_report_ul li").first().click();
	}
	parent.document.getElementById("mainContent").height=0;
	parent.document.getElementById("mainContent").height=document.body.scrollHeight;
}

function addExaminationReportRecord(){
	var examinationReportCountOjb = $("#examinationReportRecordCount");
	var count = parseInt(examinationReportCountOjb.val());
	var addli=$("#template_examination_report_ul li:eq(0)").clone();
    addli.text("记录"+(count+1));
    addli.attr("data-index",count);
    $("#examination_report_ul").append(addli);
    addli.addClass("selected").siblings().removeClass("selected");
    addli.click(function(){
    	$(this).addClass("selected").siblings().removeClass("selected");
        $("#examinationReportRecord"+$(this).attr("data-index")).show().siblings().hide();
    });
   
	var add_content=$("#templateExaminationReportRecord").clone();
	add_content.attr("id","examinationReportRecord"+count);
	add_content.find("#examinationReportItems").attr("id","examinationReportItems"+count);
	add_content.find("#examinationReportItemCount").attr("id","examinationReportItemCount"+count);
	
	add_content.find("input[name^='geElectricRecords[0].']").each(function(){
		var eventObj = $(this);
		eventObj.attr("name",eventObj.attr("name").replace("medexElectricRecords[0]", "medexElectricRecords["+count+"]"));
   		
	});
	add_content.find("textarea[name^='medexElectricRecords[0].']").each(function(){
		var eventObj = $(this);
		eventObj.attr("name",eventObj.attr("name").replace("medexElectricRecords[0]", "medexElectricRecords["+count+"]"));
   		
	});
	$("#examinationReportRecords").append(add_content);
//	if(add_content.find("table[id^='examinationReportItems'] tbody tr").length < 1){
//		addExaminationReportItem();
//	}
	add_content.show().siblings().hide();
	examinationReportCountOjb.val(count +1);
	return add_content;
}

function addExaminationReportItem(){
	var basePath = $("#basePath").val();
	
	var add_content=$("#templateExaminationReportItemTr").clone();
	add_content.removeAttr("id");
	
	var index = $("#examination_report_ul li[class='selected']").attr("data-index");
	var examinationReportItemCountOjb = $("#examinationReportItemCount"+index);
	var count = parseInt(examinationReportItemCountOjb.val());
	add_content.find("input[name^='examinationReportsRecords[0].examinationReportsItems[0].']").each(function(){
		var eventObj = $(this);
		eventObj.attr("name",eventObj.attr("name").replace("examinationReportsRecords[0].examinationReportsItems[0]", "examinationReportsRecords["+index+"].examinationReportsItems["+count+"]"));
   		
	});
	
	
	$("#examinationReportItems"+index+" tbody").append(add_content);
	examinationReportItemCountOjb.val(count +1);
	return add_content;
}

function deleteExaminationReportItem(obj){
	$(obj).parent().parent().remove();
}

function deleteExaminationReportRecord(){
	var delete_option = $("#examination_report_ul li[class='selected']");
	var delete_index = delete_option.attr("data-index");
	delete_option.remove();
	
    $("#examination_report_ul li:last").addClass("selected").siblings().removeClass("selected");
    /*内容删除最后一项*/
    $("#examinationReportRecord"+delete_index).remove();
    $("#examinationReportRecords>div:last").show().siblings().hide();
}